import { UsbAuthorizeService } from './services/usb-authorize.service';
import { WhitelistService } from './services/whitelist.service';

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { RestrictedRecordComponent } from './components/restricted-record/restricted-record.component';
import { WhiteListComponent } from './components/white-list/white-list.component';
import { WrapComponent, DialogOverviewExampleDialog } from './components/wrap/wrap.component';
import { MatIconModule, MatTabsModule } from '@angular/material';
import { ShareModule } from '../share/share.module';
import { ZoneListService } from '../log/services/zone-list.service';

import { WhitelistAddComponent } from './components/whitelist-add/whitelist-add.component';
import { WhitelistDetailComponent, PcStatusComponent, AuthStatusComponent } from './components/whitelist-detail/whitelist-detail.component';
import { WhitelistEditComponent } from './components/whitelist-edit/whitelist-edit.component';
import { RestrictedRecordService } from './services/restricted-record.service';
import { WhitelistDetailService } from './services/whitelist-details.service';


const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'table/restricted',
  },
  {
    path: '',
    data: {
      title: 'USB设备',
    },
    children: [
      {
        path: 'table',
        component: WrapComponent,
        children: [
          {
            path: 'restricted',
            component: RestrictedRecordComponent,
            runGuardsAndResolvers: 'always',
            data: {
              title: '限制记录',
            },
            resolve: {
              zone_list: ZoneListService,
              list: RestrictedRecordService,
            },
          },
          {
            path: 'whitelist',
            component: WhiteListComponent,
            runGuardsAndResolvers: 'always',
            resolve: {
              list: WhitelistService,
            },
            data: {
              title: '白名单',
            },
          },
        ],
      },
      {
        path: 'whitelist/:aliasName',
        component: WhitelistDetailComponent,
        runGuardsAndResolvers: 'always',
        data: {
          title: '设备详情',
        },
        resolve: {
          data: WhitelistDetailService,
          zone_list: ZoneListService,
          auths: UsbAuthorizeService
        },
      },
    ],
  },
];

@NgModule({
  imports: [CommonModule, ShareModule, MatTabsModule, MatIconModule, RouterModule.forChild(routes)],

  declarations: [
    RestrictedRecordComponent,
    WhiteListComponent,
    WrapComponent,
    WhitelistAddComponent,
    WhitelistDetailComponent,
    WhitelistEditComponent,
    PcStatusComponent,
    AuthStatusComponent,
    DialogOverviewExampleDialog
  ],
  entryComponents: [WhitelistAddComponent, WhitelistEditComponent, DialogOverviewExampleDialog],
})
export class UsbDeviceModule {}
